var t, e = require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../components/canvas-drag/canvas-drag"));

Page({
    data: {
        graph: {},
        screenWidth: 0,
        textToPrint: "",
        canAdd: !0,
        colorArrF: [ "black", "whitesmoke", "red", "orange", "yellow" ],
        colorArrS: [ "green", "blue", "cyan", "purple", "gray" ],
        currentColor: "black"
    },
    onLoad: function(t) {},
    onReady: function() {
        var t = wx.getSystemInfoSync().windowWidth;
        this.setData({
            screenWidth: t
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    textFinish: function(t) {
        var e = t.detail.value;
        e.length > 0 ? this.setData({
            canAdd: !1
        }) : this.setData({
            canAdd: !0
        }), this.setData({
            textToPrint: e
        });
    },
    onAddImage: function() {
        var e = this;
        wx.chooseImage({
            count: 1,
            success: function(o) {
                console.log(o), t = o.tempFilePaths[0], console.log(t), wx.getImageInfo({
                    src: t,
                    success: function(o) {
                        var n = o.height / o.width;
                        e.setData({
                            graph: {
                                w: 200,
                                h: 200 * n,
                                type: "image",
                                url: t
                            }
                        });
                    }
                });
            }
        });
    },
    onAddText: function() {
        var t = this.data;
        this.setData({
            graph: {
                type: "text",
                text: t.textToPrint
            }
        });
    },
    chooseColorF: function(t) {
        console.log(t);
        var o = t.currentTarget.id;
        this.setData({
            currentColor: o
        }), e.default.changFontColor(o);
    },
    chooseColorS: function(t) {
        var o = t.currentTarget.id;
        this.setData({
            currentColor: o
        }), e.default.changFontColor(o);
    },
    onExport: function() {
        e.default.export().then(function(t) {
            console.log(t), wx.previewImage({
                urls: [ t ]
            });
        }).catch(function(t) {
            console.error(t);
        });
    }
});